# Data analysis - Conflict and salience as drivers of corporate lobbying? #

# Loading packages
library(tidyverse)
library(broom)
library(psych)
library(ggpubr)
library(WebPower)

# Specifying variables regression
subset_foranalysis <- read.csv("subset_analyse442020.csv")
y <- subset_foranalysis$Q40_1
y2 <- subset_foranalysis$Q40_2
t <- subset_foranalysis$conflictvariable
b <- subset_foranalysis$saliencevariable
salience <- as.factor(b)
conflict<- as.factor(t)
y<- as.numeric(y)
y2<- as.numeric(y2)

#Conducting Shapiro tests
shapiro.test(y)
shapiro.test(y2)

#running ols - associational and individual lobbying
m1 <- lm(y ~ t + b)
summary(m1)

m2 <- lm(y2 ~ t + b)
summary(m2)

#Prepping for post hoc Tukey test - associational and individual lobbying
tukey.lm <- lm(y ~ conflict + salience)
tukey.av <- aov(tukey.lm)
summary(tukey.av)

tukey.lm <- lm(y2 ~ conflict + salience)
tukey.av <- aov(tukey.lm)
summary(tukey.av)

##power tests post hoc based on anova - associational and individual lobbying
wp.anova(f=0.87,k=4, n=73, alpha=0.01, power=NULL)

wp.anova(f=0.34,k=4, n=73, alpha=0.01, power=NULL)

#Tukey test
tukey.test <- TukeyHSD(tukey.av)
tukey.test
plot(tukey.test)